package com.atguigu.spzx.manager.controller;

import com.atguigu.spzx.manager.service.impl.IndexServiceImpl;
import com.atguigu.spzx.common.result.Result;
import com.atguigu.spzx.manager.vo.SysLoginReqVo;
import com.atguigu.spzx.manager.vo.SysLoginRespVo;
import com.atguigu.spzx.manager.vo.sysUser.SysUserInfoRespVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * IndexController
 * </p>
 *
 * @author flyduck
 * @since 2023/10/25
 */
@Api(tags = "用户登录接口")
@RestController
@RequestMapping("/admin/system/index")
public class IndexController {

    @Autowired
    private IndexServiceImpl indexServiceImpl;

    @ApiOperation("登录")
    @PostMapping("/login")
    public Result<SysLoginRespVo> login(@RequestBody SysLoginReqVo reqVo){
        SysLoginRespVo respVo = indexServiceImpl.login(reqVo);
        return Result.ok(respVo);
    }

    @ApiOperation("查询用户信息")
    @GetMapping("/info")
    public Result<SysUserInfoRespVo> info(@RequestHeader("token") String token){
        SysUserInfoRespVo respVo = indexServiceImpl.getUserInfo(token);
        return Result.ok(respVo);
    }
}
